package cf.huzpsb.bcgod;

import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;

import java.util.Iterator;

public class SsCMD extends Command {
    public SsCMD(String name, String permission, String... aliases) {
        super(name, permission, aliases);
    }

    public void execute(CommandSender sender, String[] args) {
        if (!(sender instanceof ProxiedPlayer)) {
            sender.sendMessage("§c后台不能使用此命令");
        } else if (args.length != 1) {
            sender.sendMessage("§c参数错误");
        } else if (((ProxiedPlayer) sender).getServer().getInfo().getName().equalsIgnoreCase(Main.login)) {
            sender.sendMessage("§c登录区域禁止使用!");
        } else {
            if (!Main.bancfg.contains(args[0])) {
                Main.bancfg.set(args[0], "T");
            }
            Iterator var17 = Main.getInstance().getProxy().getPlayers().iterator();

            while (var17.hasNext()) {
                ProxiedPlayer player1 = (ProxiedPlayer) var17.next();
                if (player1.getName().equalsIgnoreCase(args[0])) {
                    player1.sendMessage(Main.ssr);
                    sender.sendMessage("§a离线封禁设置成功!");
                    return;
                }
            }
            sender.sendMessage("§c玩家不在线,自动改为封禁!");
        }
    }
}
